package com.ynding.spring.idea.ddd.core.service.lottery.repository.impl;

import com.ynding.spring.idea.ddd.common.dal.lottery.dao.AwardDao;
import com.ynding.spring.idea.ddd.common.dal.lottery.dao.AwardPoolDao;
import com.ynding.spring.idea.ddd.core.model.lottery.domain.DrawLottery;
import com.ynding.spring.idea.ddd.core.service.lottery.repository.DrawLotteryRepository;
import com.ynding.spring.idea.ddd.core.service.lottery.cache.DrawLotteryCacheAccessObj;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

/**
 * @author ynding
 * @version 2022/9/3
 **/
@Repository
@Slf4j
public class DrawLotteryRepositoryImpl implements DrawLotteryRepository {

    private AwardDao awardDao;
    private AwardPoolDao awardPoolDao;
    private DrawLotteryCacheAccessObj drawLotteryCacheAccessObj;

    @Override
    public DrawLottery getDrawLotteryById(int lotteryId) {
        DrawLottery drawLottery = drawLotteryCacheAccessObj.get(lotteryId);
        if (drawLottery != null) {
            return drawLottery;
        }
        drawLottery = this.getDrawLotteryFromDB(lotteryId);
        drawLotteryCacheAccessObj.add(lotteryId, drawLottery);
        return drawLottery;
    }

    @Override
    public DrawLottery getDrawLotteryFromDB(int lotteryId) {
        // TODO
        return null;
    }
}
